package org.umss.fixturebuilder.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.umss.fixturebuilder.controller.ChampionshipController;
import org.umss.fixturebuilder.model.json.JsonScoreBoard;

/**
 *
 * @author Daniela Meneses
 */
@Path("/results")
public class ResultsResource {
    @GET
    @Path("/{championshipId}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response getScoreBoard(@PathParam("championshipId") String championshipId){
        JsonScoreBoard scoreBoard = ChampionshipController.getScoreBoard(championshipId);
        return scoreBoard != null ? Response.status(Response.Status.OK).entity(scoreBoard).build()
                : Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
